package cn.java.exercises;

public class Array
{
    public static void main(String[] args)
    {
        
        double dbFee[]=new double[6],dbTemp=0,dbSum=0;
        dbFee[0]=665;
        dbFee[1]=689;
        dbFee[2]=725;
        dbFee[3]=520;
        dbFee[4]=825;
        dbFee[5]=799;

        String strPlanets[]={"金","木","水","火","土","地"},strTemp="";
        char cStars[][]={
                            {' ',' ',' ','*',' ',' ',' '},
                            {' ',' ','*','*','*',' ',' '},
                            {' ','*','*','*','*','*',' '},
                            {'*','*','*','*','*','*','*'},
                            {' ','*','*','*','*','*',' '},
                            {' ',' ','*','*','*',' ',' '},
                            {' ',' ',' ','*',' ',' ',' '}
                        };

        for (int i = 0; i <dbFee.length ; i++)
        {
            dbSum+=dbFee[i];
        }

        System.out.println("总额是"+dbSum);

        for (int i = 0; i < strPlanets.length; i++)
        {
            if(i<5)
            {
                strPlanets[i] += "星";
                strTemp+=strPlanets[i]+",";
            }
            else
            {
                strPlanets[i] += "球";
                strTemp+=strPlanets[i];
            }

        }
        System.out.println("古代中国人观察到的行星有："+strTemp);

        //数组图案
        for (int i = 0; i < cStars.length; i++)
        {
            for (int j = 0; j < cStars[i].length; j++)
            {
                if(j==cStars[i].length-1)
                    System.out.println(cStars[i][j]);
                else
                    System.out.print(cStars[i][j]);
            }
        }

        
        //票房排行榜,选择排序，每次选出未排序部分大值，放入已队列
        String [] strMovies={"雷神3：诸神的黄昏","全球风暴","密战","王牌特工2:黄金圈",
                             "天才枪手","英伦对决","羞羞的铁拳","战狼2","十八洞村",
                             "缝纫机乐队"
                            };
        double [] dbBoxOffice={3.74, 3.84, 0.52, 4.64, 2.67, 5.37, 21.73, 56.76, 0.93,4.51};
        String strMovie;
        for (int i = 0; i <dbBoxOffice.length ; i++)
        {
            for (int j = i+1; j < dbBoxOffice.length; j++)
            {
                if(dbBoxOffice[i] < dbBoxOffice[j])
                {
                    dbTemp=dbBoxOffice[i];
                    dbBoxOffice[i]=dbBoxOffice[j];
                    dbBoxOffice[j]=dbTemp;
                    strMovie=strMovies[i];
                    strMovies[i]=strMovies[j];
                    strMovies[j]=strMovie;
                }
            }
        }

        System.out.println("----------选择排序-----------");
        for (int i = 0; i < dbBoxOffice.length; i++)
        {
            System.out.println("第"+(i+1)+"名 "+strMovies[i]+" \t\t票房 "+dbBoxOffice[i]);
        }

        //票房排行榜,冒泡排序，每次两两比较，较小数移动到最后
        String [] strMovies1={"雷神3：诸神的黄昏","全球风暴","密战","王牌特工2:黄金圈",
                             "天才枪手","英伦对决","羞羞的铁拳","战狼2","十八洞村",
                             "缝纫机乐队"
        };
        double []dbBoxOffice1={3.74, 3.84, 0.52, 4.64, 2.67, 5.37, 21.73, 56.76, 0.93,4.51};

        for (int i = 0; i < dbBoxOffice1.length; i++)
        {
            for (int j = 0; j < dbBoxOffice1.length -1-i; j++)
            {
                if(dbBoxOffice1[j] < dbBoxOffice1[j+1])
                {
                    dbTemp=dbBoxOffice1[j];
                    dbBoxOffice1[j]=dbBoxOffice1[j+1];
                    dbBoxOffice1[j+1]=dbTemp;
                    strMovie=strMovies1[j];
                    strMovies1[j]=strMovies1[j+1];
                    strMovies1[j+1]=strMovie;
                }
            }
        }

        System.out.println("----------冒泡排序-----------");
        for (int i = 0; i < dbBoxOffice.length; i++)
        {
            System.out.println("第"+(i+1)+"名 "+strMovies1[i]+" \t\t票房 "+dbBoxOffice1[i]);
        }
        
    }
}
